/**
 * Created by Administrator on 2018/11/13.
 */
var data = [{
    "name": "第一周",
    "value": 80
}, {
    "name": "第二周",
    "value": 87.8
}, {
    "name": "第三周",
    "value": 71
}, {
    "name": "第四周",
    "value": 80
}, {
    "name": "第五周",
    "value": 66
}, {
    "name": "第六周",
    "value": 80
}, {
    "name": "第七周",
    "value": 80
}];
var xData = [],
    yData = [];
var min = 50;
data.map(function(a, b) {
    xData.push(a.name);
    if (a.value === 0) {
        yData.push(a.value + min);
    } else {
        yData.push(a.value);
    }
});
option = {
    title: [
        {
            text: '党员学习时间',
            x: '20',
            y: '10',
            textStyle: {
                color: '#5ff9ff',
                fontSize: 16
            }
        }
        ],
    backgroundColor:"transparent",
    color: ['#3398DB'],
    tooltip: {
        trigger: 'axis',
        axisPointer: {
            type: 'line',
            lineStyle: {
                opacity: 0
            }
        },
        formatter: function(prams) {
            if (prams[0].data === min) {
                return "合格率：0%"
            } else {
                return "合格率：" + prams[0].data + "%"
            }
        }
    },
    legend: {
        data: ['直接访问', '背景'],
        show: true
    },
    grid: {
        left: '15%',
        right: '15%',
        bottom: '0%',
        top: '20%',
        height: '78%',
        containLabel: true,
        z: 22
    },
    xAxis: [{
        type: 'category',
        gridIndex: 0,
        data: xData,
        axisTick: {
            alignWithLabel: true
        },
        axisLine: {
            lineStyle: {
                color: '#0c3b71'
            }
        },
        axisLabel: {
            show: true,
            color: 'rgb(170,170,170)',
            fontSize:14
        }
    }],
    yAxis: [{
        type: 'value',
        gridIndex: 0,
        splitLine: {
            show: false
        },
        axisTick: {
            show: false
        },
        min: min,
        max: 100,
        axisLine: {
            lineStyle: {
                color: '#0c3b71'
            }
        },
        axisLabel: {
            color: 'rgb(170,170,170)',
            formatter: '{value} %'
        }
    },
        {
            type: 'value',
            gridIndex: 0,
            min: min,
            max: 100,
            splitNumber: 12,
            splitLine: {
                show: false
            },
            axisLine: {
                show: false
            },
            axisTick: {
                show: false
            },
            axisLabel: {
                show: false
            },
            splitArea: {
                show: true,
                areaStyle: {
                    color: ['rgba(250,250,250,0.0)', 'rgba(250,250,250,0.05)']
                }
            }
        }
    ],
    series: [{
        name: '合格率',
        type: 'bar',
        barWidth: '30%',
        xAxisIndex: 0,
        yAxisIndex: 0,
        itemStyle: {
            normal: {
                barBorderRadius: 30,
                color: new echarts.graphic.LinearGradient(
                    0, 0, 0, 1, [{
                        offset: 0,
                        color: '#00feff'
                    },
                        {
                            offset: 0.5,
                            color: '#027eff'
                        },
                        {
                            offset: 1,
                            color: '#0286ff'
                        }
                    ]
                )
            }
        },
        data: yData,
        zlevel: 11,
        animation:true,
        animationDuration:1000,
        animationEasing:'linear',
        animationDelay: function (idx) {
            return idx * 10;
        },
        animationDelayUpdate: function (idx) {
            return idx * 5;
        }

    },
        {
            name: '背景',
            type: 'bar',
            barWidth: '50%',
            xAxisIndex: 0,
            yAxisIndex: 1,
            barGap: '-135%',
            data: [100, 100, 100, 100, 100, 100, 100],
            itemStyle: {
                normal: {
                    color: 'rgba(255,255,255,0.1)'
                }
            },
            zlevel: 9
        },

    ]
};
var echartList1 =echarts.init(document.getElementById('echartList'))
echartList1.setOption(option);